package com.aaa.stock.controller.purch;

import com.aaa.entity.Purchase;
import com.aaa.entity.PurchaseItem;
import com.aaa.stock.service.purch.PurchaseItemService;
import com.aaa.stock.service.purch.PurchaseService;
import com.aaa.stock.vo.PurchaseItemVo;
import com.aaa.stock.vo.PurchaseVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/stock/pur/pur")
public class StockPurchController {
    @Autowired
    private PurchaseService purchaseService;
    @Autowired
    private PurchaseItemService purchaseItemService;
//采购入库
    @PostMapping("purchaseAll/{currentPage}/{pageSize}")
    public Result<IPage<Purchase>> purchaseAll(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody PurchaseVo purchaseVo
    ){
        return purchaseService.purchaseAll(currentPage,pageSize,purchaseVo);
    }
    //作废、审核通过、提交审核
    @PostMapping("SubConPass")
    public Result<String> SubConPass(
            @RequestParam("status") String status,
            @RequestBody List<Purchase> purchase
    ){
        return purchaseService.SubConPass(status,purchase);
    }
    //生产单据号
    @GetMapping("NewPurQuery")
    public Result<String> newPurQuery(){
        return purchaseService.newPurQuery();
    }
    //暂存
    @PostMapping("MomAdd")
    public Result<String> momAdd(@RequestBody Map<String,Object> map){
        return purchaseItemService.momAdd(map);
    }
//提交审核
    @PostMapping("MomAddSub")
    public Result<String> momAddSub(@RequestBody Map<String,Object> map){
        return purchaseItemService.momAddSub(map);
    }
    //查询当前单号的药品详情
    @PostMapping("ProItemAll")
    public Result<IPage<PurchaseItem>> ProItemAll(@RequestBody PurchaseItemVo purchaseItemVo){
        return purchaseItemService.proItemAll(purchaseItemVo);
    }
}
